home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / source / rotate / tile.pas < prev   
Pascal/Delphi Source File  |  1994-02-02  |  5KB  |  138 lines

  1. Program Tiles;         { by Paul H. Kahler 1994 }
  2. USES CRT;            {email:  phkahler@oakland.edu}
  3. {$G+}                {  You'll see what it does.  }
  4.  
  5. { This program is mostly undocumented. If you want to know whats going on,
  6.   see the other program, it has more comments and much of the same code, so
  7.   it should be more helpful. This version doesn't account for the non-square
  8.   pixels in mode 13h (see the other program to fix that) and it's slower
  9.   because a different fixed-point format is used (see the hloop of both
  10.   programs). I like it because it's shorter and simpler. }
  11.  
  12. { A 32x32 bitmap is defined in the data below. Feel free to change it to
  13.   whatever you like, I just punched in the first thing that came to mind. }
  14.  
  15. Const Tile: array [0..1023] of byte =
  16.    ( 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
  17.      2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  18.      2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  19.      2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  20.      2,0,0,0,0,1,1,1,1,1,0,0,1,1,1,0,0,1,0,0,0,1,0,1,0,0,0,0,0,0,0,0,
  21.      2,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,0,0,0,0,0,
  22.      2,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,0,0,0,0,0,
  23.      2,0,0,0,0,1,1,1,1,1,0,1,1,1,1,1,0,1,0,0,0,1,0,1,0,0,0,0,0,0,0,0,
  24.      2,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,0,0,0,0,0,
  25.      2,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,0,0,0,0,0,
  26.      2,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0,1,1,1,0,0,1,1,1,1,1,0,0,0,0,
  27.      2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  28.      2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  29.      2,0,0,0,0,0,0,0,0,0,0,5,5,5,5,5,0,0,5,5,5,5,0,0,0,0,0,0,0,0,0,0,
  30.      2,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  31.      2,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  32.      2,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,5,5,5,0,0,0,0,0,0,0,0,0,0,0,
  33.      2,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,
  34.      2,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,
  35.      2,0,0,0,0,0,0,0,0,0,0,5,5,5,5,5,0,5,5,5,5,0,0,0,0,0,0,0,0,0,0,0,
  36.      2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  37.      2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  38.      2,0,0,0,0,0,3,3,3,3,0,0,3,3,3,0,0,0,3,3,3,0,0,3,0,0,0,0,0,0,0,0,
  39.      2,0,0,0,0,3,0,0,0,0,0,3,0,0,0,3,0,3,0,0,0,3,0,3,0,0,0,0,0,0,0,0,
  40.      2,0,0,0,0,3,0,0,0,0,0,3,0,0,0,3,0,3,0,0,0,3,0,3,0,0,0,0,0,0,0,0,
  41.      2,0,0,0,0,3,0,0,0,0,0,3,0,0,0,3,0,3,0,0,0,3,0,3,0,0,0,0,0,0,0,0,
  42.      2,0,0,0,0,3,0,0,0,0,0,3,0,0,0,3,0,3,0,0,0,3,0,3,0,0,0,0,0,0,0,0,
  43.      2,0,0,0,0,3,0,0,0,0,0,3,0,0,0,3,0,3,0,0,0,3,0,3,0,0,0,0,0,0,0,0,
  44.      2,0,0,0,0,0,3,3,3,3,0,0,3,3,3,0,0,0,3,3,3,0,0,3,3,3,3,3,0,0,0,0,
  45.      2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  46.      2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  47.      2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 );
  48.  
  49. Var   SinTable,CosTable: Array[0..255] of longint;
  50.  
  51. Procedure MakeTables;
  52. Var direction:integer;
  53.     angle:real;
  54. begin
  55.      For Direction:=0 to 255 do begin
  56.          angle:=Direction;
  57.          angle:=angle*3.14159265/128;
  58.          SinTable[Direction]:=round(Sin(angle)*256);
  59.          CosTable[Direction]:=round(Cos(angle)*256);
  60.      end;
  61. end;
  62.  
  63. Procedure GraphMode;  {set 320x200x256 mode}
  64. begin
  65.      Asm
  66.         Mov     AH,00
  67.         Mov     AL,13h
  68.         Int     10h
  69.      end;
  70. end;
  71.  
  72. Procedure DrawScreen(x,y:word; rot,scale:byte);
  73. var Temp:Longint;
  74.     ddx,ddy,d2x,d2y:word;
  75.     i,j:word;
  76.     label hloop,vloop;
  77.  
  78. begin
  79.      Temp:=(CosTable[rot]);Temp:=(Temp*Scale) div 32;
  80.      ddx:=Temp;
  81.      Temp:=(SinTable[rot]);Temp:=(Temp*Scale) div 256;
  82.      ddy:=Temp;
  83.      Temp:=(CosTable[(rot+64) and 255]);Temp:=(Temp*SCALE) div 32;
  84.      d2x:=Temp;
  85.      Temp:=(SinTable[(rot+64) and 255]);Temp:=(Temp*SCALE) div 256;
  86.      d2y:=Temp;
  87.      i:=x-ddx*160-d2x*100; j:=y-ddy*160-d2y*100;
  88.  
  89.          ASM
  90.                  mov  ax,0
  91.                  mov  di,ax
  92.                  mov  ax,$a000
  93.                  mov  es,ax
  94.                  mov  cx,200
  95.          vloop:
  96.                  push cx
  97.                  mov  ax,[i]
  98.                  mov  dx,[j]
  99.                  mov  cx,320
  100.          hloop:
  101.                  add  ax,[ddx]
  102.                  add  dx,[ddy]
  103.                  mov  bl,ah
  104.                  mov  bh,dh
  105.                  shr  bx,3
  106.                  and  bx,$03FF
  107.                  add  bx,OFFSET tile
  108.                  mov  si,bx
  109.                  movsb
  110.                  loop hloop
  111.  
  112.                  mov  ax,d2x
  113.                  add  i,ax
  114.                  mov  ax,d2y
  115.                  add  j,ax
  116.                  pop  cx
  117.                  loop vloop
  118.          end;
  119. end;
  120.  
  121. Var dist,dd,rot,dr:byte;
  122.     x,y:word;
  123. Begin
  124.      MakeTables;
  125.      GraphMode;
  126.      x:=32768; y:=1024;
  127.      rot:=0; dr:=1;
  128.      dist:=127; dd:=255;
  129.      repeat
  130.         DrawScreen(x,y,rot,dist);
  131.         rot:=rot+dr;
  132.         y:=y+128;
  133.         dist:=dist+dd;
  134.         if (dist=250) or (dist=3) then dd:=-dd;
  135.         if random(150)=3 then begin
  136.            dr:=0; while dr=0 do dr:=random(5)-3; end;
  137.      until keypressed;
  138. end.